package com.distributer.policy.request;

import com.distributer.policy.model.InsurancePolicy;
import com.distributer.policy.service.InsurancePolicyService;

public class PolicyUpdateRequest implements Request{

	private InsurancePolicyService insurancePolicyService;
	
	private InsurancePolicy insurancePolicy;
	
	public PolicyUpdateRequest(InsurancePolicyService insurancePolicyService,InsurancePolicy insurancePolicy){
		this.insurancePolicyService = insurancePolicyService;
		this.insurancePolicy = insurancePolicy;
	}
	
	@Override
	public void prosess() {
		//删除缓存中的记录
		insurancePolicyService.removePolicyFromCacheByJbPolicyNo(getJbPolicyNo());
		//更新数据库
		insurancePolicyService.updatePolicy(insurancePolicy);
	}

	@Override
	public String getJbPolicyNo() {
		return this.insurancePolicy.getJbPolicyNo();
	}

}
